package com.avocado.configuration.repository;

import com.avocado.configuration.entity.DataDictionary;
import com.avocado.persistence.repository.BaseRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DataDictionaryRepository extends BaseRepository<DataDictionary, Long> {
	
	@Query("select count(1) from DataDictionary where key=?1")
	Long getCountByKey(String key);
		
	@Query("select count(1) from DataDictionary where key=?1 and id!=?2")
	Long getCountByKeyAndExcludeId(String key,Long excludeId);

	@Query("from DataDictionary where key=?1")
	List<DataDictionary> findAllByKey(String key);

	@Query("select count(1) from DataDictionary where  parentId=?1")
	Long getCountByParentId(Long parentId);

}
